/**  
 * All rights Reserved, Designed By daiw
 * @Title:  BaseController.java   
 * @Package org.easy.system.manage.controller   
 * @Description:    TODO (用一句话描述该文件做什么)   
 * @author: daiw     
 * @date:   2019年10月18日 上午11:59:39   
 * @Copyright: 2019 daiw Inc. All rights reserved. 
 */
package org.easy.system.manage.controller;

import javax.servlet.http.HttpServletRequest;

import org.easy.system.manage.config.RedisKey;
import org.easyframework.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.system.manage.facade.entity.UserInfoDto;
import org.system.manage.facade.entity.UserInfoSession;

import com.xxl.sso.core.conf.Conf;
import com.xxl.sso.core.user.XxlSsoUser;

/**
 * @ClassName: BaseController
 * @Description:
 * @author: daiw
 * @date: 2019年10月18日 上午11:59:39
 */
@Component
public class BaseController {
	@Autowired
	private RedisUtil redisUtil;

	protected UserInfoSession getUserInfoSession(HttpServletRequest request) {
		XxlSsoUser xxlUser = (XxlSsoUser) request.getAttribute(Conf.SSO_USER);
		return redisUtil.getObj(RedisKey.USER_SESSION_KEY + xxlUser.getUserid(), UserInfoSession.class);
	}

	protected UserInfoDto getUserInfo(HttpServletRequest request) {
		XxlSsoUser xxlUser = (XxlSsoUser) request.getAttribute(Conf.SSO_USER);
		UserInfoSession userInfoSession = redisUtil.getObj(RedisKey.USER_SESSION_KEY + xxlUser.getUserid(), UserInfoSession.class);
		return userInfoSession.getUserInfoDto();
	}
}
